<?php
header("content-type:text/html;charset=utf-8");
$pdo = new PDO("mysql:host=127.0.0.1;dbname=000","root","root");
$sql = "select * from hotgoods";
$res = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<table>
    <tbody>
    <tr>
        <td>商品名</td>
        <td>商品数量</td>
        <td>原价</td>
        <td>惊爆价</td>
        <td>操作</td>
    </tr>
    <?php foreach ($res as $val){ ?>
    <tbody>
    <tr>
        <td><?php echo $val['name']?></td>
        <td><?php echo $val['number']?></td>
        <td><?php echo $val['price']?></td>
        <td>￥1.88</td>
        <td><input type="button" id="btn" value="抢购" data-id="<?php echo $val['good_id']?>"></td>
    </tr>
    </tbody>
    <?php } ?>
    </tbody>
</table>
</body>
</html>
 